import info from './info'

/**
 * 获取屏幕比例的字体
 */
const GlobalFont = (type = 4, size = info.mainWidth) => {
	if (size > 500) {
		size = 500
	}
	var font = size * 0.008 * type
	font = parseInt(font)
	console.log('屏幕比例字体：' + font)
	return font
}

/**
 * 获取屏幕比例的横向间距
 */
const GlobalMarginWidth = (type = 4, size = info.mainWidth) => {
	var margin = size * 0.01 * type
	margin = parseInt(margin)
	console.log('屏幕比例的横向间距：' + margin)
	return margin
}

/**
 * 获取屏幕比例的竖向间距
 */
const GlobalMarginHeight = (type = 4, size = info.windowHeight) => {
	var margin = size * 0.005 * type
	margin = parseInt(margin)
	console.log('屏幕比例的竖向间距：' + margin)
	return margin
}

// 获取mac地址 - 真机有效
const getMacAddress = () => {
	var str = ''
	/**
	 * 下面代码报错
	if (plus && plus.android) {
		var net = plus.android.importClass("java.net.NetworkInterface")
		var wl0 = net.getByName('wlan0')  
		var macByte = wl0.getHardwareAddress()  
		for (var i = 0; i < macByte.length; i++) {  
			var tmp = ''
			var num = macByte[i]
			if (num < 0) {        
			  tmp = (255 + num + 1).toString(16)
			} else {  
			  tmp = num.toString(16)
			}  
			if (tmp.length == 1) {  
			  tmp = '0' + tmp 
			}  
			str += tmp 
		}
		if (str) {
			console.log('Mac地址：' + str)
		}
	}
	 */
	return str
}

module.exports = {
	GlobalFont,
	GlobalMarginWidth,
	GlobalMarginHeight,
	getMacAddress
}